﻿using HCQ2_Common;
using HCQ2_Model;
using HCQ2_Model.ViewModel;
using HCQ2_Model.VR.Params;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace HCQ2UI_Logic.DocumentController
{
    /// <summary>
    ///  教学统计控制器
    /// </summary>
    public class TeachController: BaseLogic
    {
        //**********************************1.0教学统计列表页************************************
        #region 1.0 教学统计进入管理界面 + ActionResult List()
        /// <summary>
        ///  教学统计进入管理界面
        /// </summary>
        /// <returns></returns>
        [HCQ2_Common.Attributes.Load]
        [HCQ2_Common.Attributes.Element]
        [HttpGet]
        public ActionResult List()
        {
            return View();
        }
        #endregion

        #region 1.1 获取Table数据 + ActionResult GetDocTreeData()
        /// <summary>
        ///  获取Table数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetTeachData(ExperienceParam param)
        {
            int total;
            List<T_VRExperienceMain> list = operateContext.bllSession.T_VRExperienceMain.GetExperienceList(param,out total);
            TableModel tModel = new TableModel()
            {
                total = total,
                rows = list
            };
            return Json(tModel, JsonRequestBehavior.AllowGet);
        }
        #endregion

        #region 1.2 获取单位数据 + ActionResult GetUnitTreeData()
        /// <summary>
        ///  获取单位数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetUnitTreeData()
        {
            return Json(operateContext.bllSession.T_VRExperienceMain.GetUnitData());
        }
        #endregion

        //**********************************2.0教学统计详细**************************************
        #region 2.0 教学统计详细进入 + ActionResult DetialList()
        /// <summary>
        ///  教学统计详细进入
        /// </summary>
        /// <returns></returns>
        [HCQ2_Common.Attributes.Load]
        [HCQ2_Common.Attributes.Element]
        [HttpGet]
        public ActionResult DetialList()
        {
            return View();
        }
        #endregion

        #region 1.1 获取Table数据 + ActionResult GetDetialData()
        /// <summary>
        ///  获取Table数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetDetialData()
        {
            int user_id = RequestHelper.GetIntByName("user_id"),
                file_id = RequestHelper.GetIntByName("file_id"),
                rows = RequestHelper.GetIntByName("rows"),
                page = RequestHelper.GetIntByName("page");
            int total = operateContext.bllSession.T_VRExperienceRecord.SelectCount(s => s.user_id == user_id && s.file_id == file_id);
            List<T_VRExperienceRecord> list = operateContext.bllSession.T_VRExperienceRecord.Select(s => s.user_id == user_id && s.file_id == file_id, s => s.in_date, page, rows);
            TableModel tModel = new TableModel()
            {
                total = total,
                rows = list
            };
            return Json(tModel, JsonRequestBehavior.AllowGet);
        }
        #endregion
    }
}